<%--
  Created by IntelliJ IDEA.
  User: pc
  Date: 2025/1/4
  Time: 14:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="zh-CN">
<head>
    <title>注册页面</title>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/static/plugins/bootstrap-4.6.2-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/static/plugins/bootstrap-icons-1.11.3/font/bootstrap-icons.min.css">
</head>
<body>
<div class="container">
    <%--    mt-5 : margin top 的简写--%>
    <div class="row mt-5">
        <div class="col-1"></div>
        <div class="col-10">
            <div class="card mb-3 shadow-lg" >
                <div class="row no-gutters">
                    <%--                    <div class="col-md-3">--%>
                    <%--                        <img src="<%=request.getContextPath()%>/static/images/reg-left.jpeg" style="width: 200px; height: 540px" alt="...">--%>
                    <%--                    </div>--%>
                    <div class="col-md-12">
                        <div class="card-body">
                            <h5 class="card-title text-center">用户注册</h5>
                            <p class="card-text">
<%--                                表单提交--%>
                            <form method="post" action="<%=request.getContextPath()%>/user/register" enctype="multipart/form-data">
                                <div class="form-group">
                                    <label for="username">用户名</label>
                                    <input type="text" class="form-control" id="username" name="username">
                                    <small id="usernametips" class="form-text text-muted">请输入正确的用户名.</small>
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputEmail1">邮箱</label>
                                    <input type="email" name="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
                                    <small id="emailHelp" class="form-text text-muted">请输入正确的邮箱.</small>
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputPassword1">密码</label>
                                    <input type="password" class="form-control" id="exampleInputPassword1" name="password">
                                    <small id="passwordHelp" class="form-text text-muted">请输入正确的密码.</small>
                                </div>
                                <!-- 添加昵称输入 -->
                                <div class="form-group">
                                    <label for="full_name">昵称</label>
                                    <input type="text" class="form-control" id="full_name" name="full_name">
                                    <small id="full_name_tips" class="form-text text-muted">请输入您的昵称（非必填）.</small>
                                </div>
                                <!-- 添加头像上传 -->
                                <div class="form-group">
                                    <label for="profile_picture">上传头像</label>
                                    <input type="file" class="form-control-file mr-3" id="profile_picture" name="profile_picture">
                                    <small id="profile_picture_tips" class="form-text text-muted">请上传头像（非必填）.</small>
                                </div>

                                <!-- 新增的单选框部分 -->
                                <div class="form-group">
                                    <label>用户类型</label><br>
                                    <label for="ordinary_user">
                                        <input type="radio" id="ordinary_user" name="user_type" value="1" checked> 普通用户
                                    </label>
                                    <label for="admin_user" class="ml-3">
                                        <input type="radio" id="admin_user" name="user_type" value="2"> 管理员用户
                                    </label>
                                </div>

                                <!-- 添加一个隐藏的字段来传递 status 值 -->
                                <input type="hidden" id="status" name="status" value="1"> <!-- 默认是普通用户 -->

                                <button type="submit" class="btn btn-primary">注册</button>
                                <button type="reset" class="btn btn-secondary">重置</button>
                            </form>
                            </p>
<%--                            <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>--%>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-1"></div>
    </div>
</div>
<script src="<%=request.getContextPath()%>/static/plugins/jquery/jquery.slim.min.js"></script>
<script src="<%=request.getContextPath()%>/static/plugins/bootstrap-4.6.2-dist/js/bootstrap.bundle.js"></script>
<%--<script src="<%=request.getContextPath()%>/static/js/user/register.js"></script>--%>
<script>
    // 当用户选择不同的单选框时，更新隐藏的 status 字段
    document.querySelectorAll('input[name="user_type"]').forEach(function (radio) {
        radio.addEventListener('change', function () {
            var status = document.getElementById('status');
            if (document.getElementById('ordinary_user').checked) {
                status.value = '1'; // 普通用户
            } else if (document.getElementById('admin_user').checked) {
                status.value = '2'; // 管理员用户
            }
        });
    });
</script>
</body>
</html>
